package socilgirl.dell.mydemo.view;

import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;
import socilgirl.dell.mydemo.R;

public class VoidPlayActivity extends AppCompatActivity {

//    private RecyclerView mRecycleView;
    private SensorManager sensorManager;
    private JCVideoPlayer.JCAutoFullscreenListener jcListener;
    private JCVideoPlayerStandard jcVoid;
    private String str1 = "http://pic.ibaotu.com/00/43/71/197888piCiXU.mp4";
    String imageUrl="http://a4.att.hudong.com/05/71/01300000057455120185716259013.jpg";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_void_play);
//        mRecycleView = findViewById(R.id.rc_common_recycleview);
        sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
        jcListener = new JCVideoPlayer.JCAutoFullscreenListener();
        jcVoid = findViewById(R.id.void_jiecaovoid);
        ImageView imageView = jcVoid.thumbImageView;
        Glide.with(this).load(imageUrl).into(imageView);
        jcVoid.setUp(str1,jcVoid.SCREEN_LAYOUT_NORMAL,"视频播放");
    }

    @Override
    protected void onResume() {
        super.onResume();
        sensorManager.unregisterListener(jcListener);
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    protected void onDestroy() {

        super.onDestroy();
        sensorManager.unregisterListener(jcListener);
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()){
            return;
        }
        super.onBackPressed();
    }
}
